package com.chasmcity.munrobagging;

import static java.util.Collections.*;

import com.chasmcity.munrobagging.data.MunroCsvReader;
import com.chasmcity.munrobagging.model.Munro;

import java.io.IOException;
import java.util.List;

import android.app.Application;
import android.content.Context;
import android.util.Log;

/**
 * TODO: Missing class description for MunroBaggingApp!
 * <p>
 * &copy; Copyright 2011 Kizoom Ltd.
 * <p>
 * $Id: wildebeest_standard.epf,v 1.9 2007/01/17 14:59:59 danf Exp $
 */
public class MunroBaggingApp extends Application {
	
	private List<Munro> munros;

	@Override
	public void onCreate() {
		super.onCreate();
		
		Log.i("MunroBaggingApp", "Reading munro data from CSV");
		try {
			munros = unmodifiableList(new MunroCsvReader().read());
		} catch (IOException ex) {
			throw new IllegalStateException(ex);
		}
		Log.i("MunroBaggingApp", "Read " + munros.size() + " from CSV");
	}
	
	public static List<Munro> getMunros(Context context) {
		return ((MunroBaggingApp)context.getApplicationContext()).munros;
	}
}
